$(function(){

    //时尚资讯
    var fashionInfor ={
        inforData:{},  //轮播图信息
    };

    /**
     * 初始化获取时尚资讯信息
     * **/
    fashionInfor.initInfor = function(){
        $.ajax({
            async: false,
            url: '/information/findInforFashion',
            success: function (result) {
                if (result && result.code == 200) {
                    if (result.data != '') {
                       var $newsHtml =  $('.fashion-news');
                        var htmlNew = '';
                       $.each(result.data,function(key,obj){
                           if( key < 8 ) {
                               htmlNew +='<div class="fashion-new">';
                           }else{
                               htmlNew +='<div class="fashion-new module-display-hide">';
                           }
                           if( key%2==0 ){
                               htmlNew += '<a href="/web/information?type=1&id=' + obj.id + '"><img src="' + obj.url + '" alt="" ></a>';
                               htmlNew += '<div class="fashion-content">';
                               htmlNew += '<span class="fashion-title"  title="' + obj.title + '"><a href="/web/information?type=1&id=' + obj.id + '">' + obj.title + '</a></span>';
                               htmlNew += '<span class="fashion-message">' + (obj.brief==null?"":obj.brief) + '</span>';
                               htmlNew += '<time class="fashion-time">' + obj.releaseTime.split(" ")[0] + '</time>';
                               htmlNew +='</div>';
                           }else{
                               htmlNew += '<div class="fashion-content">';
                               htmlNew += '<span class="fashion-title" title="' + obj.title + '"><a href="/web/information?type=1&id=' + obj.id + '">' + obj.title + '</a></span>';
                               htmlNew += '<span class="fashion-message">' + (obj.brief==null?"":obj.brief) + '</span>';
                               htmlNew += '<time class="fashion-time">' + obj.releaseTime.split(" ")[0] + '</time>';
                               htmlNew +='</div>';
                               htmlNew += '<a href="/web/information?type=1&id=' + obj.id + '"><img src="' + obj.url + '" alt="" ></a>';
                           }
                           htmlNew +='</div>';
                       });
                        $newsHtml.find('.fashion-new').remove();
                        $newsHtml.append(htmlNew);
                        if( result.data.length >8 )
                            $newsHtml.append( '<button class="load-more">加载更多</button>');

                        $('.load-more').on('click',function(){
                            var maxShow = 4;
                            var moreBtn = $(this);
                            if($('.module-display-hide').length > 0){
                                $('.module-display-hide').each(function(index){
                                    if( index < maxShow )
                                        $(this).removeClass("module-display-hide");
                                });

                                //当没有需要加载的数据时
                                if($('.module-display-hide').length == 0){
                                    moreBtn.css("display","none");
                                }
                            }

                        });
                    }
                }
            },
            error: function () {
                layer.alert('服务器出错啦！', {icon: 2, title: '错误'});
            }
        });
    }

    //初始化
    fashionInfor.initInfor();
    header.selLiCss("infor");
    //面包屑名称
    $("#menu-ico span").html("•&nbsp;&nbsp;资讯&nbsp;&nbsp;•&nbsp;&nbsp;时尚资讯");
});